/*
 
 Copyright (C) 2009 Id Software, Inc.
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */

#import <UIKit/UIKit.h>
#import <UIKit/UIAccelerometer.h>
#import "../koth/JWEntity.h"

@class EAGLView;
@class JWLandscape;


@interface wolf3dAppDelegate : NSObject <UIApplicationDelegate, /*UIAccelerometerDelegate,*/ UITextFieldDelegate> {
    UIWindow* window;
    EAGLView* glView;
	IBOutlet UIWebView* webView;
	
	
	IBOutlet UIImageView* titleScreen;
	
	int		lastAccelUpdateMsec;
	
	// Title screen buttons.
	IBOutlet UIButton* play;
	IBOutlet UIButton* resume;
	IBOutlet UIButton* about;
	IBOutlet UIButton* help;
	IBOutlet UIButton* controls;
	IBOutlet UIButton* chooseLevel;
	IBOutlet UIButton* mute;
	IBOutlet UIButton* dashboard;
	
	// Back button.
	IBOutlet UIButton* backButton;
	
	// Intermission screen button.
	IBOutlet UIButton* enterGame;
	
	// Level select buttons and textbox.
	IBOutlet UIButton* previous;
	IBOutlet UIButton* next;
	
	IBOutlet UIButton* levelLabelButton;
	IBOutlet UILabel* levelLabel;
	IBOutlet UILabel* dimensionLabel;
	IBOutlet UILabel* energyLabel;
	UITextField* textField;
	
	// In-game buttons.
	IBOutlet UIButton* teleport;
	IBOutlet UIButton* absorb;
	IBOutlet UIButton* box;
	IBOutlet UIButton* robot;
	IBOutlet UIButton* tree;
	IBOutlet UIButton* uturn;
	
	// Hacky flags...
	BOOL resuming;
	BOOL controlTest;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet EAGLView *glView;

//- (void)restartAccelerometerIfNeeded;

// Title screen actions.
-(IBAction)resume:(id)sender;
-(IBAction)about:(id)sender;
-(IBAction)help:(id)sender;
-(IBAction)controls:(id)sender;
-(IBAction)chooseLevel:(id)sender;
-(IBAction)mute:(id)sender;
-(IBAction)dashboard:(id)sender;

// Back action.
-(IBAction)back:(id)sender;

// Intermission action.
-(IBAction)enterGame:(id)sender;

// Level select actions.
-(IBAction)previous:(id)sender;
-(IBAction)next:(id)sender;
-(IBAction)levelSelect:(id)sender;
-(void)doneButton:(id)sender;

// In-game actions.
-(IBAction)teleport:(id)sender;
-(IBAction)absorb:(id)sender;
-(IBAction)box:(id)sender;
-(IBAction)robot:(id)sender;
-(IBAction)tree:(id)sender;
-(IBAction)uturn:(id)sender;
-(void)emergencyTeleportCanDie:(BOOL)canDie;

// Hiding stuff.
-(void)hideTitleScreen:(BOOL)hide;
-(void)hideLevelSelectScreen:(BOOL)hide;
-(void)hideGameScreen:(BOOL)hide;
-(void)hideAllExceptBack;
-(void)hidePreviousNext:(BOOL)hide;

#pragma mark Postion stuff.
-(void)positionLevelSelectUI;
-(void)positionGameUI;
-(void)positionTitleScreenUI;

// Utility stuff.
-(void)addEntity:(NSObject<JWEntity>*)entity;
-(void)incrementLevel;
-(void)incrementLevel:(NSUInteger)amount;
-(void)decrementLevel;
-(void)newLevel:(NSUInteger)level;
-(void)keyboardWillShow:(NSNotification*)note;
-(void)setLevelText;
-(void)updateHealthDisplay;
-(void)updateOpenFeintWithCompletedLandscape:(JWLandscape*)landscape;
-(void)playerDied;
-(void)tryControls;
-(void)muteSounds:(BOOL)aMute;

@end

